var url = require('url');
var template = require('templateConfig');
var main = require('main');
var form = require('form');
var module = require('module');

//模板配置
var tplArr = [];
var portTpl =require('raw!../template/product-port.txt'); 
tplArr['port'] = template.compile(portTpl.replace(/^\s*|\s*$/g, "")); 
 
function Index(){
    _this = this;
    this.main = function(){
        main.event(this,'tap','i-click'); 
        this.init();
    }     
    this.getContent = function(){

        main.get(url.inventoryList,{"product_id":_this.product_id},function(ret){
            _this.data = ret;
            var goodsInfo = [{
                        "id": 1,
                        "title":"大家乐文胸一片式无痕内衣厚B杯深V聚拢商场同款内衣1",
                        "inStock":"258",
                        "price":"99",
                    }];
            var cupSelect = (function(o){ 
                        var option = [];
                        for(var n in o){
                            option.push({"name":o[n],"value":o[n]});
                        }
                        return option;
                    })(_this.data.cup); 
            var data = {
                tType: "content",
                num: "10028978874",
                goods: module.ordersGoodsInfo(goodsInfo,"ordersGoodsInfo"),
                
                select:module.getModule({"fun":'om-change="selectFun"',"list":cupSelect,"selected":"1"},'baseSelect'),
                tabList:[{
                        color: "大红",
                        size: "32/70",
                        inStock: "20"
                    },{
                        color: "大红",
                        size: "32/70",
                        inStock: "0"
                    }]
            }
            $(".content").html(tplArr['port'](data));
        });
    	
    }
    //罩杯类型切换
    this.selectCup = function(ths){

    }
    this.init= function(){ 
        this.product_id = main.GetQueryString('product_id')||"";
        this.getContent();  
    }
    return this.main();
};

var index = new Index();